package cn.bugstack.xfg.dev.tech.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * Web配置类 - 配置静态资源映射
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        // 映射根路径到HTML文件目录
        registry.addResourceHandler("/**")
                .addResourceLocations("file:docs/dev-ops/nginx/html/")
                .setCachePeriod(0); // 开发环境不缓存，便于调试

        // 也可以添加classpath下的静态资源
        registry.addResourceHandler("/static/**")
                .addResourceLocations("classpath:/static/")
                .setCachePeriod(3600); // 1小时缓存
    }
}
